var a = require("../../utils/httpPost.js"), t = require("../../component/microPage/common/data/index.js"), 
s = getApp();

Page({
  static: {
    imgurl: s.getImgUrl(),
    userId: 0,
    pageId: 0,
    title: "活动页"
  },
  data: {
    dataIsLoad: false,
    pageData: {},
    pageIndex:1
  },
  onLoad: function (a) {
    console.log('smallPage onLoad a',a)
    this.static.pageId = parseInt(a.id), this.static.userId = s.getUserId();
    this.loadData();
  },
  onShow: function (a) {
    var t = this.data, s = t.dataIsLoad, o = t.pageData;
    s && (o.list || this.loadData());
  },
  onPullDownRefresh: function () {
    wx.stopPullDownRefresh(), this.loadData();
  },
  /**
   * 获取页面数据的 http请求
   */
  loadData: function () {
    var that = this
    a.httpPost('/titleMenu/list', {
      title_menu_id: this.static.pageId,
      pagesize: 20,
      pageindex: that.data.pageIndex
    }, function (res) {
      console.log('活动页页数据', res)
      if (res.data.code == 0) {
        that.data.pageIndex = that.data.pageIndex + 1
        wx.setNavigationBarTitle({
          title: res.data.data.page.titleName
        })
        that.setData({
          isLoading: false, loading: true, netWork: true, dataIsLoad:true,
          sections: res.data.data.sections
        });
      } else {
        that.setData({ isLoading: false, loading: true, netWork: true, dataIsLoad: false })
      }
      // complete
      wx.hideNavigationBarLoading() //完成停止加载
      wx.stopPullDownRefresh() //停止下拉刷新
    }, function () {
      that.setData({ isLoading: false, loading: true, netWork: true, dataIsLoad: false})
    })
  }
});